PhreeqPython + VIPhreeqc Functionality Overview


In [1]:
import phreeqpython
pp = phreeqpython.PhreeqPython()

Adding Solutions


In [2]:
# Simple, through a reaction block
solution = pp.add_solution_simple({'CaCl2':1.0,'NaHCO3':2.0},temperature=15)
# Complex, allowing for more 'standard' PHREEQC input (Phreeqc example 3 -- Mixing)
solution2 = pp.add_solution({'units':'ppm',
                                 'pH': 8.22,
                                 'pe': 8.451,
                                 'density': 1.023,
                                 'temp': 25.0,
                                 'Ca': 412.3,
                                 'Mg': 1291.8,
                                 'Na': 10768.0,
                                 'K': 399.1,
                                 'Si': 4.28,
                                 'Cl': 19353.0,
                                 'Alkalinity': '141.682 as HCO3',
                                 'S(6)': 2712.0
                                })

Solution Information

Basic Properties


In [4]:
print("Solution pH: {:.3}".format(solution.pH))
print("Solution sc: {:3.2f}".format(solution.sc))
print("Solution pe: {:.3}".format(solution.pe))
print("Temperature: {:.3}".format(solution.temperature))
print("Mass:        {:.3}".format(solution.mass))


Solution pH: 8.23
Solution sc: 335.25
Solution pe: 10.5
Temperature: 15.0
Mass:        1.0

Speciation


In [5]:
solution.species


Out[5]:
{'CH4': 0.0,
 'CO2': 2.7909024983359043e-05,
 'CO3-2': 1.504189457564534e-05,
 'Ca+2': 0.0009734342277295038,
 'CaCO3': 1.1724417168794343e-05,
 'CaHCO3+': 1.4819423174432155e-05,
 'CaOH+': 2.1931927102669182e-08,
 'Cl-': 0.0020000000000000005,
 'H+': 6.3511969105813895e-09,
 'H2': 0.0,
 'H2O': 55.50932491627957,
 'HCO3-': 0.0019282729745638734,
 'Na+': 0.001997767734466099,
 'NaCO3-': 2.4888466990103817e-07,
 'NaHCO3': 1.983380863998685e-06,
 'NaOH': 1.4165712953779178e-19,
 'O2': 1.880500103837165e-15,
 'OH-': 8.235839079271772e-07}

Elements


In [6]:
solution.elements


Out[6]:
{'C(4)': 0.002000000000000004,
 'Ca': 0.000999999999999833,
 'Cl': 0.0020000000000000005,
 'Na': 0.001999999999999999,
 'O(0)': 3.76100020767433e-15}

Phases and their SI


In [7]:
solution.phases


Out[7]:
{'Aragonite': 0.1932078777270103,
 'CH4(g)': -125.58800591273227,
 'CO2(g)': -3.216751152245572,
 'Calcite': 0.34442418867614855,
 'Fix_pH': -8.226383714702244,
 'H2(g)': -37.424312956480996,
 'H2O(g)': -1.7694469897527798,
 'Halite': -7.024441375036288,
 'O2(g)': -11.912977050671959,
 'Vaterite': -0.2494038522747335}

Element and Species sums


In [9]:
solution.total_element('Cl', units='mmol')


Out[9]:
2.0000000000000004

In [10]:
solution.total('HCO3', units='mg') # equavalent to SUM_SPECIES


Out[10]:
118.68237757085221

Modifying Solutions

Adding and Removing


In [11]:
solution.add('NaOH',1, 'mmol')              # add 1 mmol of NaOH
solution.remove('NaCl',1, 'mmol')           # remove 1 mmol of NaCl
solution.remove_fraction('CO3',0.5) # remove 50% of CO3


Out[11]:
<phreeqpython.solution.Solution at 0x10e854668>

Saturation and Desaturation


In [13]:
solution.saturate('Calcite',1.0)    # Saturate to SI 1.0
solution.desaturate('Calcite',0.0)  # Desaturate to SI 0.0


Out[13]:
<phreeqpython.solution.Solution at 0x10e854668>

Changing pH


In [14]:
solution.change_ph(5,'HCl')         # Change pH to 5 by dosing HCl
solution.pH


Out[14]:
5.0

Changing Temperature


In [16]:
solution.change_temperature(10)     # Change temperature to 10 degrees
solution.temperature


Out[16]:
10.0

Mixing Solutions


In [23]:
solution1 = pp.add_solution_simple({'NaCl':1})
solution2 = pp.add_solution_simple({'NaCl':3})
# make a solution of 50% solution 1 and 50% solution 2:
solution3 = solution1 * 0.5 + solution2 * 0.5
# make a solution by mixing solution 1 and 2 together
solution4 = solution1 + solution2
print("Solution 3:")
print("Total Chloride: {:.3} mmol".format(solution3.total('Cl')))
print("Mass: {:.3}".format(solution3.mass))
print("")
print("Solution 4:")
print("Total Chloride: {:.3} mmol".format(solution4.total('Cl')))
print("Mass: {:.3}".format(solution4.mass))


Solution 3:
Total Chloride: 2.0 mmol
Mass: 1.0

Solution 4:
Total Chloride: 4.0 mmol
Mass: 2.0

Misc. Functionality

Copying Solutions


In [25]:
solution5 = solution4.copy()
print(solution5.sc)


245.0526302945747

Forgetting solutions


In [26]:
solution5.forget()